package com.lt.accesscontrolmanager.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lt.accesscontrolmanager.domain.AccessControlDevice;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
* @author Administrator
* @description 针对表【access_control_device(门禁设备表)】的数据库操作Mapper
* @createDate 2024-09-27 10:37:01
* @Entity generator.domain.AccessControlDevice
*/
@Mapper
public interface AccessControlDeviceMapper extends BaseMapper<AccessControlDevice> {

    int deleteByPrimaryKey(Long id);

    int insert(AccessControlDevice record);

    int insertSelective(AccessControlDevice record);

    AccessControlDevice selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(AccessControlDevice record);

    int updateByPrimaryKey(AccessControlDevice record);




    @Insert("INSERT INTO access_control_device (principal, supplier, brand, building_id, status, add_time) " +
            "VALUES (#{principal}, #{supplier}, #{brand}, #{buildingId}, #{status}, #{addTime})")
    void addDevice(AccessControlDevice device);

    @Update("UPDATE access_control_device SET status = #{status} WHERE id = #{id}")
    void updateDeviceStatus(@Param("id") Long id, @Param("status") int status);



//    @Select("select a.*,b.name from access_control_device a left join building b on a.building_id=b.id where a.building=#{building}")
//    Page<AccessControlDevice> selectData(Page<AccessControlDevice> page,String buildingId);


    @SelectProvider(type = SqlBuilder.class, method = "buildSelectByBuildingId")
    Page<AccessControlDevice> selectData(Page<AccessControlDevice> page, @Param("buildingId") String buildingId);



}
